﻿using System;
using System.Configuration;
using System.Collections.Generic;

namespace Vision.VisionWorkshop.Common
{
    /// <summary>
    /// 
    /// </summary>
    public class ToolboxConfigSection : ConfigurationSection
    {
        [ConfigurationProperty("ToolboxItems")]
        public ToolboxItemCollection ToolboxItems
        {
            get { return ((ToolboxItemCollection)(base["ToolboxItems"])); }
        }    
    }

    /// <summary>
    /// 
    /// </summary>
    [ConfigurationCollection(typeof(ToolboxItemElement))]
    public class ToolboxItemCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new ToolboxItemElement();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ToolboxItemElement)(element)).ToolName;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="idx"></param>
        /// <returns></returns>
        public ToolboxItemElement this[int idx]
        {
            get { return (ToolboxItemElement)BaseGet(idx); }
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public class ToolboxItemElement : ConfigurationElement
    {
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("ToolName", DefaultValue = "", IsKey = true, IsRequired = true)]
        public string ToolName
        {
            get { return ((string)(base["ToolName"])); }
            set { base["ToolName"] = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("AssemblyName", DefaultValue = "", IsKey = false, IsRequired = false)]
        public string AssemblyName
        {
            get { return ((string)(base["AssemblyName"])); }
            set { base["AssemblyName"] = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [ConfigurationProperty("DisplayName", DefaultValue = "", IsKey = false, IsRequired = false)]
        public string DisplayName
        {
            get { return ((string)(base["DisplayName"])); }
            set { base["DisplayName"] = value; }
        }

        [ConfigurationProperty("Group", DefaultValue = "", IsKey = false, IsRequired = false)]
        public string Group
        {
            get { return ((string)(base["Group"])); }
            set { base["Group"] = value; }
        }
    }
}
